---------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Users\sbstjp\OneDrive - Cardiff University\FinalHarvard\Appendix2.3.log
  log type:  text
 opened on:  12 May 2025, 16:33:57

. use "C:\Users\sbstjp\OneDrive - Cardiff University\anes_pilot_2024_dta_20240319.dta" // American National Ele
> ction Study 2024 Pilot Study, March 19, 2024 Version. Date accessed: March 09, 2025.

. 
. keep if sample_type == 1 // Only keep those respondents with proper weight, as advised in codebook
(409 observations deleted)

. 
. //Demographic items
. *Delete missing values and rename
. replace faminc_new = . if inlist(faminc_new, 97, -7) 
(143 real changes made, 143 to missing)

. replace ideology_lcself= . if inlist(ideology_lcself, -1, -7) 
(2 real changes made, 2 to missing)

. rename gender FemaleGender

. 
. *Generate dummies
. gen Graduate=. 
(1,500 missing values generated)

. replace Graduate=0 if inrange(educ, 1, 4) 
(964 real changes made)

. replace Graduate=1 if inlist(educ, 5, 6)
(536 real changes made)

. 
. gen BIPOC=. 
(1,500 missing values generated)

. replace BIPOC=0 if race==1
(1,021 real changes made)

. replace BIPOC=1 if inrange(race, 2, 7)
(479 real changes made)

. 
. //Create social justice scale
. *Delete missing values
. replace group_antifa= . if inlist(group_antifa, -7, 999)
(22 real changes made, 22 to missing)

. 
. *Generate a dummy variable for raceadvantage
. gen raceadwhite=. 
(1,500 missing values generated)

. replace raceadwhite=1 if raceadvt_white==3 & raceadvt_whitestr==1
(43 real changes made)

. replace raceadwhite=2 if raceadvt_white==3 & raceadvt_whitestr==2
(66 real changes made)

. replace raceadwhite=3 if raceadvt_white==3 & raceadvt_whitestr==3
(32 real changes made)

. replace raceadwhite=4 if raceadvt_white==2
(683 real changes made)

. replace raceadwhite=5 if raceadvt_white==1 & raceadvt_whitestr==3
(44 real changes made)

. replace raceadwhite=6 if raceadvt_white==1 & raceadvt_whitestr==2
(218 real changes made)

. replace raceadwhite=7 if raceadvt_white==1 & raceadvt_whitestr==1
(414 real changes made)

. 
. *Reverse code certain items so social justice values are high
. foreach var in police_number trans_health school_gender {
  2.     qui sum `var'
  3.     local max_value = r(max)
  4.     gen r`var' = `max_value' + 1 - `var'
  5. }

. 
. *Standardize items in the scale from 1-2 - this avoids 0, for reasons outlined in next step
. foreach var in rschool_gender rtrans_health rpolice_number raceadwhite group_blm group_antifa {
  2.     summarize `var'
  3.     gen s_`var' = 1 + (`var' - r(min)) / (r(max) - r(min))
  4. }

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
rschool_ge~r |      1,500    2.257333    1.280184          1          5

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
rtrans_hea~h |      1,500       2.106    1.290429          1          5

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
rpolice_nu~r |      1,500       2.372    1.046747          1          5

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
 raceadwhite |      1,500    4.952667    1.626096          1          7

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
   group_blm |      1,500    43.94267     35.8946          0        100

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
group_antifa |      1,478    27.85927    29.56254          0        100
(22 missing values generated)

. 
. * At this point, the scale has a Cronbach's Alpha of 0.82
. 
. * Replace missing values with 0 for the specified variables - this is necessary as Stata doesn't add up missi
> ng values and means a 0-1 standardization scale isn't feasible as missing values would overlap with the scale
. foreach var in s_rschool_gender s_rtrans_health s_rpolice_number s_raceadwhite s_group_blm s_group_antifa {
  2.     replace `var' = 0 if missing(`var')
  3. }
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(22 real changes made)

. 
. * Initialize the total score and the count of non-zero responses
. gen total_score = 0

. gen count_nonzero = 0

. 
. * Add each variable to the total scale score and count it if non-zero
. foreach var in s_rschool_gender s_rtrans_health s_rpolice_number s_raceadwhite s_group_blm s_group_antifa {
  2.     replace total_score = total_score + `var'
  3.     replace count_nonzero = count_nonzero + (`var' != 0)
  4. }
(1,500 real changes made)
(1,500 real changes made)
(1,500 real changes made)
(1,500 real changes made)
(1,500 real changes made)
(1,500 real changes made)
(1,500 real changes made)
(1,500 real changes made)
(1,500 real changes made)
(1,500 real changes made)
(1,478 real changes made)
(1,478 real changes made)

. 
. * Calculate the average score, avoiding division by zero
. gen SocJusValues = . 
(1,500 missing values generated)

. replace SocJusValues = total_score / count_nonzero if count_nonzero > 0
(1,500 real changes made)

. 
. // Standardize
. egen Age = std(age)

. egen Income = std(faminc_new)
(143 missing values generated)

. 
. // Regression models
. regress SocJusValues Age BIPOC FemaleGender Graduate Income [pweight=weight], robust 
(sum of wgt is 1,347.97601471471)

Linear regression                               Number of obs     =      1,357
                                                F(5, 1351)        =      54.53
                                                Prob > F          =     0.0000
                                                R-squared         =     0.1709
                                                Root MSE          =     .20539

------------------------------------------------------------------------------
             |               Robust
SocJusValues | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
         Age |  -.0675612   .0064453   -10.48   0.000    -.0802051   -.0549173
       BIPOC |     .08385   .0135804     6.17   0.000     .0572091     .110491
FemaleGender |  -.0051028   .0122314    -0.42   0.677    -.0290974    .0188918
    Graduate |   .0997286   .0144785     6.89   0.000     .0713258    .1281313
      Income |  -.0132623   .0071025    -1.87   0.062    -.0271954    .0006708
       _cons |    1.33659   .0217129    61.56   0.000     1.293996    1.379185
------------------------------------------------------------------------------

. eststo 
(est1 stored)

. regress SocJusValues Age BIPOC FemaleGender Graduate Income if ideology_lcself<4 [pweight=weight], robust 
(sum of wgt is 454.6790618318051)

Linear regression                               Number of obs     =        448
                                                F(5, 442)         =       2.33
                                                Prob > F          =     0.0417
                                                R-squared         =     0.0278
                                                Root MSE          =     .16812

------------------------------------------------------------------------------
             |               Robust
SocJusValues | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
         Age |  -.0234154   .0093215    -2.51   0.012    -.0417353   -.0050955
       BIPOC |  -.0053856   .0186463    -0.29   0.773     -.042032    .0312607
FemaleGender |  -.0034084   .0176343    -0.19   0.847    -.0380659    .0312491
    Graduate |   .0337932   .0201713     1.68   0.095    -.0058503    .0734368
      Income |   .0044651   .0100222     0.45   0.656     -.015232    .0241623
       _cons |   1.562143   .0297857    52.45   0.000     1.503604    1.620682
------------------------------------------------------------------------------

. eststo 
(est2 stored)

. esttab

--------------------------------------------
                      (1)             (2)   
             SocJusValues    SocJusValues   
--------------------------------------------
Age               -0.0676***      -0.0234*  
                 (-10.48)         (-2.51)   

BIPOC              0.0839***     -0.00539   
                   (6.17)         (-0.29)   

FemaleGender     -0.00510        -0.00341   
                  (-0.42)         (-0.19)   

Graduate           0.0997***       0.0338   
                   (6.89)          (1.68)   

Income            -0.0133         0.00447   
                  (-1.87)          (0.45)   

_cons               1.337***        1.562***
                  (61.56)         (52.45)   
--------------------------------------------
N                    1357             448   
--------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

. 
. log close
      name:  <unnamed>
       log:  C:\Users\sbstjp\OneDrive - Cardiff University\FinalHarvard\Appendix2.3.log
  log type:  text
 closed on:  12 May 2025, 16:34:07
---------------------------------------------------------------------------------------------------------------
